package com.example.smarthome;

public class SmartTV extends SmartDevice {
    private int channel;
    private int volume;

    public SmartTV(String id, String name) {
        super(id, name);
        this.channel = 1;
        this.volume = 20;
    }

    public void setChannel(int channel) {
        if (channel <= 0) {
            System.out.println("频道号无效！");
            return;
        }
        this.channel = channel;
        System.out.println(deviceName + " 切换到频道 " + channel);
    }

    public void setVolume(int volume) {
        if (volume < 0 || volume > 100) {
            System.out.println("音量范围应在 0-100 之间！");
            return;
        }
        this.volume = volume;
        System.out.println(deviceName + " 音量设置为 " + volume);
    }

    @Override
    public String getDeviceType() {
        return "智能电视";
    }

    @Override
    public String getStatus() {
        return String.format("[%s] 状态：%s，频道：%d，音量：%d",
                deviceName, isOn ? "开启" : "关闭", channel, volume);
    }
}